package edu.gmu.messages;

import edu.gmu.middleware.Message;
import edu.gmu.streams.BlockInputStream;
import edu.gmu.streams.BlockOutputStream;
import java.io.IOException;

/* this class represents a single user */
public class ReplicateRequest implements Message
{
    //public String fileName;
    public EndPoint primary;
    public int id = -1;
    public byte[] file;
  
    public ReplicateRequest()
    {

    }

    public void marshal(BlockOutputStream stream) throws IOException
    {
        this.primary.marshal(stream);
        stream.writeInt(this.id);
        stream.writeInt( this.file.length );
        stream.write(file);
    }
    public void unmarshal(BlockInputStream stream) throws IOException
    {
        this.primary = new EndPoint();
        this.primary.unmarshal(stream);
        this.id = stream.readInt();
        int length = stream.readInt();
        this.file = new byte[length];
        stream.read(file);
    }
}
